package com.pty.mainservice.component;

import com.alibaba.fastjson.JSONObject;
import com.pty.mainservice.dto.UserDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * Created by pty on 2017/12/25
 */
@Slf4j
@Component
public class MqReceiver {

    @RabbitListener(queues = "queue")
    public void receive(String msg) {
        log.info("这是我收到的MSG >> {}", msg);
    }

    @RabbitListener(queues = "queueBean")
    public void receiveBean(String msg) {
        UserDTO userDTO = JSONObject.parseObject(msg, UserDTO.class);
        log.info("这是我收到的MSGBean >> {}", userDTO.toString());
    }

    @RabbitListener(queues = "topic.message")
    public void receiveTopicMsg(String msg) {
        log.info("这是我收到的MSG >> {}", msg);
    }

    @RabbitListener(queues = "topic.messages")
    public void receiveTopicMsgs(String msg) {
        log.info("这是我收到的MSG topic.messages >> {}", msg);
    }

    @RabbitListener(queues = "topic.messagea")
    public void receiveTopicMsga(String msg) {
        log.info("这是我收到的MSG topic.messageaaaaaaaaaaaa >> {}", msg);
    }

}
